home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / ACORNUSERS / CBSA / COMPUTER / WIMP2 / Docs / APIs next >
Text File  |  1999-02-18  |  15KB  |  405 lines

  1. Wimp enhancer module API details (v0.34 - 17th February 1999):
  2. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  3.  
  4. The Wimp enhancer module provides kernel and wimp extensions and
  5. enhancements for RISC-OS. This API documentation is split into several
  6. sections: SWIs, Service Calls and the 17, 18 & 19 codes handler.
  7.  
  8. It is assumed that the programmer is familiar with Acorn RISC-OS and
  9. especially with the operation and construction of programs for the Acorn
  10. RISC-OS Wimp.
  11.  
  12.  
  13.  SWIs:
  14.  -=-=-
  15.  Wimp2_Version                            (&C0040)
  16.  On entry: Nothing
  17.  On exit:
  18.   R0=version of this module * 100
  19.   R1=version of RISC-OS present * 100
  20.   R2=version of floating point emulator * 100
  21.   R3=number of Wimp2 processes currently running
  22.   R4=base of Wimp2 heap
  23.   R5=number of dynamic area used by Wimp2 (if on RO3.5+). Zero otherwise.
  24.  Use:
  25.    This call returns useful information about Wimp2 and its internals.
  26.  
  27.  Wimp2_ReadMonotonicTime                    (&C0041)
  28.  On entry: Nothing
  29.  On exit:
  30.   R0=low word of timer
  31.   R1=high word of timer
  32.  Use:
  33.    This call returns the value of a timer incremented 1000 times a second.
  34.  
  35.  Wimp2_CallAfter                        (&C0042)
  36.  On entry:
  37.   R0=time from now to call routine in ms
  38.   R1=addr of routine
  39.   R2=R12 on entry
  40.  On exit: All preserved
  41.  Use:
  42.    This call calls the specified code at R1 after R0 milliseconds have
  43. elapsed with R12 set to R2 on entry.
  44.    Your code is called in supervisor mode with interrupts enabled and so you
  45. should take the usual precautions for calling SWIs and such. Note that you
  46. should not take time when called by this method as the system is
  47. effectively hung while you are in this call. You may corrupt R0, R1 and R12
  48. if you wish.
  49.  
  50.  Wimp2_StopCallAfter                        (&C0043)
  51.  On entry:
  52.   R0=addr of routine
  53.   R1=R12 on entry
  54.  On exit: All preserved
  55.  Used:
  56.    This call stops the scheduled call set up by Wimp2_CallAfter.
  57.  
  58.  Wimp2_Initialise                        (&C0044)
  59.  On entry:
  60.   R0=version of module expected * 100
  61.   R1=ptr to name of this program instance
  62.   R2=ptr to routine to handle poll codes 17, 18 & 19
  63.  On exit:
  64.   R0=version of this support module * 100
  65.   R1=version of the RO Wimp * 100
  66.   R2=Wimp2 task handle of this app
  67.   R3=RO Wimp task handle of this app
  68.  Use:
  69.    This call registers your program with the Wimp2 multitasker. On your
  70. behalf Wimp_Initialise is called, and preemptive multitasking is started
  71. immediately. Service calls are issued during the execution of this call - see
  72. below.
  73.    NOTE: the routine for handling 17, 18 & 19 return codes is *immediately*
  74. valid and may be started at any time - so make sure it's valid.
  75.  
  76.  Wimp2_Closedown                        (&C0045)
  77.  On entry:
  78.   R0=wimp task handle (0 for current task)
  79.  On exit: Nothing
  80.  Use:
  81.    This call stops preemptively multitasking your task and calls
  82. Wimp_CloseDown on your behalf. Normally you now exit using OS_Exit as per
  83. normal - or if you wish you can continue execution.
  84.  
  85.  Wimp2_Poll                            (&C0046)
  86.  On entry:
  87.   R0=poll mask as for RO Wimp_Poll (except bit 0 has changed - see below)
  88.   R1=ptr to 256 bytes to have poll data returned into
  89.  On exit:
  90.   R0=wimp poll reason code
  91.   R1=preserved
  92.   R2=second timer
  93.  Use:
  94.    Use this call to fetch wimp messages sent to you by other wimp tasks.
  95.    Note however that if you have not called Wimp2_Poll recently that the
  96. messages returned may be significantly out of date. Therefore you should
  97. examine R2 against the last time you called Wimp2_Poll and if deemed
  98. necessary, throw away messages returned. You should not need to throw away
  99. redraw messages as these are collated for you anyway.
  100.    Messages returned are identical in format to Wimp_Poll: except that of
  101. the redraw window request message (1) which is returned as the following
  102. format instead:
  103.      +00: window handle
  104.      +04: work area min x
  105.      +08: work area min y
  106.      +12: work area max x
  107.      +16: work area max y
  108.    This message upon being received should be passed to Wimp2_RedrawWindow -
  109. see its entry for details.
  110.    One difference between this call and RO Wimp_Poll is bit 0 - under RO,
  111. this prevents code zeros returning. Under Wimp2, this suspends preemption
  112. if there are no messages in the queue to be processed, only restarting it
  113. if a new message arrives. In most cases this difference will not be
  114. significant.
  115.    Finally please note the poll mask does *not* affect results being returned
  116. immediately - only new ones being received.
  117.  
  118.  Wimp2_RedrawWindow                        (&C0047)
  119.  On entry:
  120.   R1=ptr to redraw block (see Wimp2_Poll for format)
  121.  On exit:
  122.   R0=flag on whether to continue
  123.  Use:
  124.    This call is very similar to Wimp_UpdateWindow except that when called
  125. preemption is halted. Wimp2_GetRectangle should then be called as
  126. necessary in the same fashion as Wimp_GetRectangle.
  127.    As said above, preemption is halted during the redraw cycle. Therefore
  128. you should try to make the redraw as quick as possible.
  129.    Unlike Wimp_RedrawWindow, this call may also be called at any time to
  130. update a window.
  131.  
  132.  Wimp2_GetRectangle                        (&C0048)
  133.  On entry:
  134.   R1=as for Wimp_GetRectangle
  135.  On exit:
  136.   R0 & R1 as for Wimp_GetRectangle
  137.  Use:
  138.    Use this call like Wimp_GetRectangle.
  139.  
  140.  Wimp2_OpenTemplate                        (&C0049)
  141.  On entry:
  142.   R1=as for Wimp_OpenTemplate
  143.  On exit: Nothing
  144.  Use:
  145.    This call disables preemption and makes the call to Wimp_OpenTemplate for
  146. you.
  147.  
  148.  Wimp2_CloseTemplate                        (&C004A)
  149.  On entry: Nothing
  150.  On exit: Nothing
  151.  Use:
  152.    This call makes the call to Wimp_CloseTemplate for you and reenables
  153. preemption.
  154.  
  155.  Wimp2_NeedReset                        (&C004B)
  156.  On entry: Nothing
  157.  On exit:
  158.   R0=zero if everything alright,
  159.        ptr to error blk of error if reset required
  160.  Use:
  161.    Use this call to check if your error handler was called through an error
  162. occuring during the execution of the module's preemption handlers.
  163.    If R0 returns a non zero result, you can check the error code to see what
  164. you should do. For example, if it is a fairly transient error (eg; Not a
  165. block) which indicates data corruption of the module's lists then a restart
  166. will more than likely work so you should shut yourself down using
  167. Wimp2_Closedown and restart with Wimp2_Initialise.
  168.    Finally, note that memory full errors get dealt with internally by the
  169. preemptor routine and you should not receive these. If you do, something is
  170. seriously wrong and you should quit rather than restart.
  171.  
  172.  Wimp2_ReportError                        (&C004C)
  173.  On entry:
  174.   R0=ptr to std error blk
  175.   R1=flags
  176.   R2=name of application
  177.  On exit:
  178.   R0=1 for OK, 2 for Cancel
  179.  Use:
  180.    Use this call to open a multitasking error box. This isn't implemented in
  181. this version of Wimp2.
  182.  
  183.  Wimp2_EnumerateTasks                        (&C004D)
  184.  On entry:
  185.   R0=0 for first call
  186.  On exit:
  187.   R0=updated to internal pointer, becomes <0 when finished enumeration
  188.   R1=Wimp2 task handle
  189.   R2=RO task handle
  190.   R3=name of task
  191.   R4=maximum slice in ms this task can have
  192.   R5=actual time in ms taken by this task so far
  193.   R6=threads running in this task
  194.  Use:
  195.    Use this call to see what tasks are currently being preempted by the Wimp2
  196. module.
  197.  
  198.  Wimp2_SetTaskData                        (&C004E)
  199.  On entry:
  200.   R1=Wimp2 task handle
  201.   R4=maximum slice in ms to give to this whole task
  202.      (0=leave the same, -1=effectively disables preemption)
  203.   R5=new actual time taken
  204.      (<0=leave the same)
  205.  On exit:
  206.   R0-R3=preserved
  207.   R4=former max slice
  208.  Use:
  209.    Use this call to set the maximum slice and time taken for this Wimp2
  210. task. 
  211.  
  212.  Wimp2_KillProcess                        (&C004F)
  213.  On entry:
  214.   R0=Wimp2 task handle
  215.  On exit:
  216.   All registers preserved
  217.  Use:
  218.    Use this call to kill a specific Wimp2 process. Firstly, a quit message is
  219. sent to the top of the process's poll queue. If the task has not quit in five
  220. seconds, the process' environment vectors will be delinked and the exit
  221. vector will be attempted. If this succeeds or returns an error, no matter, as
  222. Wimp2_CloseDown and OS_Exit is called for the task on its behalf.
  223.    This call is the severest way to shut down a Wimp2 process. It will leave
  224. memory allocated, files open etc. and it should not be used except in an
  225. emergency.
  226.    Note that the call returns immediately, and if you are not a preempted
  227. task you should call Wimp_Poll soon to allow the task a chance to process the
  228. quit message.
  229.    NOTE: This call is not implemented in the present version of the Wimp2
  230. module
  231.  
  232.  Wimp2_CopyMemory                        (&C0060)
  233.  On entry:
  234.   R0=ptr to src
  235.   R1=ptr to dest
  236.   R2=length in bytes to copy
  237.  On exit:
  238.   All registers preserved
  239.  Use:
  240.    Use this call to copy memory from one place to another using an optimised
  241. memory copying routine. The routine correctly handles overlapping areas and
  242. non-word aligned sources or destinations or lengths.
  243.    This routine can copy 44 bytes at a time, nearly the most possible on the
  244. Arm processor. Hence it works especially well when copying large portions of
  245. memory, although FIQ operation may be disrupted.
  246.    Note that the routine is much slower when copying non-aligned areas ie;
  247. two areas at the same offset from a word aligned address will use the fast
  248. routine which uses direct 44 byte copies. Non aligned areas require bytes to
  249. be shifted to match the new alignment and hence are far far slower.
  250.    The routine has been optimised for the Arm6 processor ie; it assumes the
  251. presence of at least a 4k instruction cache and a write buffer. This
  252. configuration is not necessary for the correct operation of the routine
  253. however.
  254.  
  255.  Wimp2_CopyStringXX                        (&C0061)
  256.  On entry:
  257.   R0=ptr to src
  258.   R1=ptr to dest
  259.   R2=lower terminating character
  260.   R3=upper terminating character
  261.  On exit:
  262.   R1=ptr to terminator of dest
  263.   R2=length of the string
  264.  Use:
  265.    Use this call to copy a string from one place to another using an
  266. optimised copying routine. Specify a range of terminating characters using R2
  267. and R3 eg; copy yea string terminated by anything from a 0 to a 31. Note that
  268. the copied string is terminated by R2, not by the original terminator. The
  269. routine correctly handles overlapping strings.
  270.  
  271.  Wimp2_FindStringLengthXX                    (&C0062)
  272.  On entry:
  273.   R0=ptr to string
  274.   R1=lower terminating character
  275.   R2=upper terminating character
  276.  On exit:
  277.   R0=ptr to terminating character
  278.   R1=length of string
  279.  Use:
  280.    Use this call to find the length of a string which may be terminated by
  281. any character between R1 and R2 inclusively. The routine is highly optimised
  282. and so will find the length extremely quickly.
  283.  
  284.  Wimp2_Divide                            (&C0063)
  285.  On entry:
  286.   R0=number to be divided
  287.   R1=number to divide by
  288.  On exit:
  289.   R0=result
  290.   R1=modulus
  291.  Use:
  292.    Use this call to divide R0 by R1 returning the result and the modulus.
  293. This call uses an optimised divide routine.
  294.  
  295.  
  296.  
  297.  Service Calls:
  298.  -=-=-=-=-=-=-=
  299.  Wimp2_PreWimpPoll                        (&C0040)
  300.  On entry:
  301.   R1=&C0040, this service call's number
  302.   R2=Wimp2 task handle of the task about to have Wimp_Poll called for it
  303.  On exit:
  304.   Ensure all registers are the same ie; do not claim this call
  305.  Use:
  306.   This service call is issued by the Wimp2 module just prior to the call to
  307. Wimp_Poll made by Wimp2 on the behalf of the preempted task.
  308.  
  309.  Wimp2_PostWimpPoll                        (&C0041)
  310.  On entry:
  311.   R1=&C0041, this service call's number
  312.   R2=Wimp2 task handle of the task which has just received control
  313.  On exit:
  314.   Ensure all registers are the same ie; do not claim this call
  315.  Use:
  316.   This service call is issued by the Wimp2 module just after Wimp_Poll,
  317. called by Wimp2 on the behalf of the preempted task, has returned. Also, if
  318. poll code number two was returned by Wimp_Poll, suitable Wimp_RedrawWindow
  319. and Wimp_GetRectangle calls will have been made to collect the necessary
  320. bounding rectangles prior to this call.
  321.  
  322.  Wimp2_PreInitialise                        (&C0042)
  323.  On entry:
  324.   R1=&C0042, this service call's number
  325.  On exit:
  326.   Ensure all registers are the same ie; do not claim this call
  327.  Use:
  328.   This service call is issued by the Wimp2 module just after Wimp2_Initialise
  329. is called. It is intended for the patch module so that it can not bother
  330. trying to intercept the Wimp_Initialise Wimp2_Initialise does.
  331.  
  332.  Wimp2_PostInitialise                        (&C0043)
  333.  On entry:
  334.   R1=&C0043, this service call's number
  335.  On exit:
  336.   Ensure all registers are the same ie; do not claim this call
  337.  Use:
  338.   This service call is issued by the Wimp2 module just before
  339. Wimp2_Initialise returns. It is intended for the patch module so that it can
  340. not bother trying to intercept the Wimp_Initialise Wimp2_Initialise does.
  341.  
  342.  Wimp2_PointerLeavingWindow                    (&C0044)
  343.  On entry:
  344.   R1=&C0044, this service call's number
  345.   R2=Wimp2 task handle of the task which has just received the message
  346.  On exit:
  347.   Set R1 to zero to claim call
  348.  Use:
  349.   This service call is issued by the Wimp2 module when a
  350. Pointer_Leaving_Window (4) message is received by a Wimp2 task. This is to
  351. allow a suitable Hourglass module patch to switch off the hourglass state for
  352. that task.
  353.  
  354.  Wimp2_PointerEnteringWindow                    (&C0045)
  355.  On entry:
  356.   R1=&C0045, this service call's number
  357.   R2=Wimp2 task handle of the task which has just received the message
  358.  On exit:
  359.   Set R1 to zero to claim call
  360.  Use:
  361.   This service call is issued by the Wimp2 module when a
  362. Pointer_Entering_Window (5) message is received by a Wimp2 task. This is to
  363. allow a suitable Hourglass module patch to switch on the hourglass state for
  364. that task.
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  17, 18 & 19 poll code API
  372.  -=-=-=-=-=-=-=-=-=-=-=-=-
  373.  
  374. In C, your routine will be called as follows:
  375.  
  376. int routine(int msgno, int msgblk)
  377.  
  378. In assembler, this goes to:
  379.  
  380. R0=poll code number
  381. R1=message block attached to poll code number
  382.  
  383. You should return in R0 a value to indicate what should be done with this
  384. message:
  385.  0: This causes the message to be placed in the normal message queue to be
  386. handled by Wimp2_Poll called by the main process.
  387.  1: This tells the module that the message has been dealt with and to take no
  388. further action.
  389.  2: This tells the module to halt preemption and feed the message to the next
  390. Wimp2_Poll called, and thereafter restart preemption on the next after that
  391. Wimp2_Poll called. This is intended for the wimp patch ONLY.
  392.  Other return values are currently reserved.
  393.  
  394. Note that any changes you make to the message block pointed to by R1 are
  395. permanent ie; it is directly the message block that will be put in the
  396. message queue if R0=0 on exit. This can be advantageous or not.
  397.  
  398. Note also that this routine is NOT preempted. Therefore you should be fast to
  399. finish your business. Also be aware that your have 256 bytes of stack
  400. available and currently no more - if you extend over that you will invoke the
  401. C stack extender and then things will become very nasty indeed as in fact the
  402. stack resides in 'limbo' in RMA. So *ensure* this doesn't happen.
  403.  
  404. Please see the enclosed C example for how to implement this.
  405.